package com.douqu.game.core.entity.world.map;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-04-26 16:24
 */
public class WorldMapUpdateResult {

    /**
     * 可以开始战斗的匹配组
     */
    private List<MapMatchTeam> startBattleMatchTeamList;

    /**
     * 占领城信息
     */
    private Map<Integer, OccupyCityParam> occupyCityMap;

    private Map<Integer, List<SpritePlayerBean>> removePlayerMap;

    /**
     * 要变成恢复状态的玩家
     */
    private List<SpritePlayerBean> recoverPlayerList;

    /**
     * 要删除的远征军
     */
    private Map<Integer, List<SpriteExpeditionBean>> removeExpeditionMap;


    public WorldMapUpdateResult()
    {
        startBattleMatchTeamList = new CopyOnWriteArrayList<>();
        occupyCityMap = new ConcurrentHashMap<>();
        recoverPlayerList = new CopyOnWriteArrayList<>();
        removeExpeditionMap = new HashMap<>();
        removePlayerMap = new HashMap<>();
    }

    public void addRecoverPlayer(SpritePlayerBean playerBean)
    {
        recoverPlayerList.add(playerBean);
    }

    public void addRemoveSprite(int cityId, SpriteBean spriteBean)
    {
        if(spriteBean instanceof SpritePlayerBean)
        {
            List<SpritePlayerBean> list = removePlayerMap.get(cityId);
            if(list == null)
            {
                list = new ArrayList<>();
                removePlayerMap.put(cityId, list);
            }
            list.add((SpritePlayerBean) spriteBean);
        }
        else if(spriteBean instanceof SpriteExpeditionBean)
        {
            List<SpriteExpeditionBean> list = removeExpeditionMap.get(cityId);
            if(list == null)
            {
                list = new ArrayList<>();
                removeExpeditionMap.put(cityId, list);
            }
            list.add((SpriteExpeditionBean) spriteBean);
        }

    }

    public void addStartBattleMatchTeam(MapMatchTeam mapMatchTeam)
    {
        startBattleMatchTeamList.add(mapMatchTeam);
    }


    public void addOccupyCity(int city, OccupyCityParam param)
    {
        occupyCityMap.put(city, param);
    }


    public Map<Integer, OccupyCityParam> getOccupyCityMap() {
        return occupyCityMap;
    }

    public List<MapMatchTeam> getStartBattleMatchTeamList() {
        return startBattleMatchTeamList;
    }



    public List<SpritePlayerBean> getRecoverPlayerList() {
        return recoverPlayerList;
    }

    public Map<Integer, List<SpriteExpeditionBean>> getRemoveExpeditionMap() {
        return removeExpeditionMap;
    }

    public Map<Integer, List<SpritePlayerBean>> getRemovePlayerMap() {
        return removePlayerMap;
    }
}
